PROJECT(serialize)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
INCLUDE(CheckIncludeFileCXX)

SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_DEBUG_POSTFIX d)

INCLUDE_DIRECTORIES(./ ./include/)
AUX_SOURCE_DIRECTORY(. DIR_SRCS)

SET(CJSON "./thirdParty/cjson/cJSON.h" "./thirdParty/cjson/cJSON.c")
SOURCE_GROUP("thirdParty\\cjson" FILES ${CJSON})

SET(INCLUDE "./include/serialize.h")
SOURCE_GROUP(include FILES ${INCLUDE})

SET(INCLUDEJSON "./include/json/encoder.h" "./include/json/decoder.h")
SOURCE_GROUP("include\\json" FILES ${INCLUDEJSON})

SET(INCLUDECJSON "./include/cjson/CJSONEncoder.h" "./include/cjson/CJSONDecoder.h")
SOURCE_GROUP("include\\cjson" FILES ${INCLUDECJSON})

SET(INCLUDEPROTOBUF "./include/protobuf/encoder.h" "./include/protobuf/decoder.h")
SOURCE_GROUP("include\\protobuf" FILES ${INCLUDEPROTOBUF})

SET(SRCJSON "./src/json/encoder.cpp" "./src/json/decoder.cpp")
SOURCE_GROUP("src\\json" FILES ${SRCJSON})

SET(SRCCJSON "./src/cjson/CJSONEncoder.cpp" "./src/cjson/CJSONDecoder.cpp")
SOURCE_GROUP("src\\cjson" FILES ${SRCCJSON})

SET(SRCPROTOBUF "./src/protobuf/encoder.cpp" "./src/protobuf/decoder.cpp")
SOURCE_GROUP("src\\protobuf" FILES ${SRCPROTOBUF})

LIST(REMOVE_ITEM DIR_SRCS "./tester/main.cpp")
IF (MSVC)
    ADD_LIBRARY(serialize SHARED ${CJSON} ${INCLUDE} ${INCLUDEJSON} ${INCLUDECJSON} ${INCLUDEPROTOBUF} ${SRCJSON} ${SRCCJSON} ${SRCPROTOBUF} ${DIR_SRCS})
ELSE ()
    ADD_LIBRARY(serialize ${CJSON} ${INCLUDE} ${INCLUDEJSON} ${INCLUDECJSON} ${INCLUDEPROTOBUF}  ${SRCJSON} ${SRCCJSON} ${SRCPROTOBUF} ${DIR_SRCS})
ENDIF (MSVC)


SET(EXEC OFF CACHE BOOL "")
if (${EXEC} STREQUAL ON)
    SET(TESTER "./tester/main.cpp" "./tester/testStruct.h")
    SOURCE_GROUP(tester FILES ${TESTER})
    ADD_EXECUTABLE(tester ${TESTER})
    TARGET_LINK_LIBRARIES(tester serialize)
endif()
